'use strict';

/**
 * @ngdoc function
 * @name newWfApp.controller:MainCtrl
 * @description
 * # MainCtrl
 * Controller of the newWfApp
 */
angular.module('newWfApp')
        .controller('HumanTaskDetailController', function ($scope, $http, $routeParams) {

            $scope.reserveTask = reserveTask;
            $scope.completeTask = completeTask;

            loadTask();

            function loadTask() {
                $http.get('http://10.28.6.9:8080/NDK_WF_AL/task/load/' + $routeParams.taskId)
                        .then(function (response) {
                            $scope.task = response.data.taskAbstract;
                        });
            }

            function reserveTask() {
                $http.get('http://10.28.6.9:8080/NDK_WF_AL/task/reserve/' + $routeParams.taskId)
                        .then(function (response) {
                            loadTask();
                        });
            }

            function completeTask() {
                $http.get('http://10.28.6.9:8080/NDK_WF_AL/task/complete/' + $routeParams.taskId)
                        .then(function (response) {
                            loadTask();
                        });
            }


        });

